package com.nineclock.auth.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

@Configuration
public class TokenConfig {

    //JWT令牌生成时的签名秘钥 ;
//    private static final String SING_KEY = "6A2811E15281EC7A4EB20088A7B0645A";

    @Value("${nineclock.auth.signKey}")
    private String SING_KEY;

    @Bean
    public TokenStore tokenStore(){
        // jwt token
        return new JwtTokenStore(tokenConverter());
    }

    @Bean
    public JwtAccessTokenConverter tokenConverter(){
        JwtAccessTokenConverter tokenConverter = new JwtAccessTokenConverter();
        //设置 加密 密钥
        tokenConverter.setSigningKey(SING_KEY);
        return  tokenConverter;
    }
}